package day1;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Demo1 {
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        int left= in.nextInt();
        int right=in.nextInt();
        int count=0;
        for(int i=left;i<=right;i++){
            int t=i;
            while(t!=0){
                if(t%10==2)count++;
                t/=10;
            }
        }
        System.out.println(count);
    }


    public ArrayList<Integer> intersection1 (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        HashSet<Integer>set=new HashSet<>();
        for (int i = 0; i <nums1.size() ; i++) {
            for (int j = 0; j <nums2.size() ; j++) {
                if(nums1.get(i)==nums2.get(j)){
                    set.add(nums1.get(i));
                }
            }
        }
        ArrayList<Integer>ret=new ArrayList<>(set);
        return ret;
    }

    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
HashSet<Integer>set=new HashSet<>(nums1);
HashSet<Integer>set1=new HashSet<>();
        for (int i = 0; i <nums2.size() ; i++) {
            if (set.contains(nums2.get(i))){
                set1.add(nums2.get(i));
            }
        }
        return new ArrayList<>(set1);

    }


}
